const utilsModel = require('@/models/utils.model')
const JsonResult = require('@/utils/httpResponse.util')

class UtilsController {
  async findConfig (req, response) {
    try {
      const data = await utilsModel.findConfig()
      JsonResult.success({
        req,
        response,
        data,
        message: '查询成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '查询失败' })
    }
  }

  async updateConfig (req, response) {
    try {
      const data = await utilsModel.updateConfig(req.body)
      JsonResult.success({
        req,
        response,
        data,
        message: '更新成功'
      })
    } catch (error) {
      JsonResult.fail({ req, response, error, message: '更新失败' })
    }
  }
}

module.exports = new UtilsController()
